﻿using UnityEngine;
using System.Collections;

public class WireLinear : Wire {

	public float slope = 1;
	public float midpoint = 0.5f;
	public float noise = 0;
		
	public ushort probeInputAxon;
	public ushort probeOutputSoma;
	
	void FixedUpdate () {

		float v = 0;
		probeInputAxon = neuronInput.axon;
		v = neuronInput.axon / 65534.0f;
		v = Mathf.Clamp01 (v);
		probeInputFloat = v;

		v = midpoint + (v - 0.5f) * slope + Random.Range (-noise, noise);
		v = Mathf.Clamp01 (v);
		probeOutputFloat = v;

		probeOutputSoma = (ushort)(v * 65534.0f);	
		neuronOutput.synapse -= 32767;
		neuronOutput.synapse += probeOutputSoma;
		/*long t = neuronOutput.soma;
		t += probeOutputSoma;
		t -= 32767;
		t = (long) Mathf.Clamp (t, 0, 65534);
		neuronOutput.soma = (ushort)t;*/

	}

	public void randomize() {
		midpoint += Random.Range (-1.0f, 1.0f)/4;
		slope += Random.Range (-1.0f, 1.0f)/4;
	}


	
}
